#ifndef __BINARYTREEHEAP_H__
#define __BINARYTREEHEAD_H__

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>

//once define pointer size
#define ONCE_SPACE (4)

//type define binary tree heap data 
typedef int BTHeapData;
//type define binary tree heap struct and binary tree heap struct pointer
typedef struct BTHeap
{
	BTHeapData* pdata;
	int capacity;
	int size;
}BTHeap, * PBTHeap;

//swap binary tree heap data
void Swap(BTHeapData* p1, BTHeapData* p2);

//MAX heap top adjust up binary tree heap data
void MaxAdjustUp(BTHeapData* pdata, int index);

//MAX heap top adjust down binary tree heap data
void MaxAdjustDown(BTHeapData* pdata, int index, int size);


//MIN heap top adjust up binary tree heap data
void MinAdjustUp(BTHeapData* pdata, int index);

//MIN heap top adjust down binary tree heap data
void MinAdjustDown(BTHeapData* pdata, int index, int size);


//binary tree heap init
void HeapInit(PBTHeap pheap);

//binary tree heap destroy
void HeapDestroy(PBTHeap pheap);


//binary tree heap push data
void HeapPush(PBTHeap pheap, BTHeapData value);

//binary tree heap pop data
void HeapPop(PBTHeap pheap);


//return binary tree heap top data
BTHeapData HeapTop(PBTHeap pheap);

//return binary tree heap data empty
//if heap equal to empty; return true
//else return false
bool HeapEmpty(PBTHeap pheap);

//print binary tree heap
void PrintHeap(PBTHeap pheap);

//array adjust up to heap
void ArrayToMaxHeap(int* arr, int len);

//array adjust up to heap
void ArrayToMinHeap(int* arr, int len);

//print array
void PrintArray(int* arr, int len);

//heap shot adjust MAX down -> ascending order
void HeapShotUp(int* arr, int len);

//heap shot adjust MIN down -> descending order
void HeapShotDown(int* arr, int len);


#endif /*__BINARYTREEHEAP_H__*/